﻿using System;

namespace _05方法练习
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("请输入数字");
            int number = GetNumber(Console.ReadLine());
            Console.WriteLine(number);
            Console.ReadKey();
        }
        public static int GetNumber(string s)
        {
            while(true)
            {
                try
                {
                    int number = Convert.ToInt32(s);
                    return number;
                }
                catch
                {
                    Console.WriteLine("请重新输入!!!!");
                    s = Console.ReadLine();
                }
            }
        }
    }
}
